//package com.netty.esc.http.common.kafka;
//
//import com.alibaba.fastjson.JSON;
//import com.alibaba.fastjson.JSONObject;
//import com.alibaba.fastjson.serializer.SerializerFeature;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.kafka.core.KafkaTemplate;
//import org.springframework.kafka.support.SendResult;
//import org.springframework.stereotype.Component;
//import org.springframework.util.concurrent.ListenableFuture;
//import org.springframework.util.concurrent.ListenableFutureCallback;
//
///**
// * @Author: zhaoyang05
// * @Data: 2022/3/24 17:27
// * @Description
// * kafka生产者
// */
//@Component
//@Slf4j
//public class Producer {
//
//    @Autowired
//    private KafkaTemplate<String, Object> kafkaTemplate;
//
//    private static final String TOPIC = "healthy";
//
//    private static final String TOPIC_GROUP1 = "FIRST_BLADE";
//
//    public void send(Object obj) {
//        String obj2String = JSON.toJSONString(obj, SerializerFeature.WriteMapNullValue);
//        //log.info("准备发送消息为：{}", obj2String);
//        //发送消息
//        ListenableFuture<SendResult<String, Object>> future = kafkaTemplate.send(TOPIC, obj2String);
//        future.addCallback(new ListenableFutureCallback<SendResult<String, Object>>() {
//            @Override
//            public void onFailure(Throwable throwable) {
//                //发送失败的处理
//                log.info(TOPIC + " - 生产者 发送消息失败：" + throwable.getMessage());
//            }
//
//            @Override
//            public void onSuccess(SendResult<String, Object> stringObjectSendResult) {
//                //成功的处理
//                log.info(TOPIC + " - 生产者 发送消息成功：" + stringObjectSendResult.toString());
//            }
//        });
//
//
//    }
//}
